(() => {
	let ele = {};
	ele.jinjie2 = $('#jinjie2');
	ele.jinjie2 = $('#jinjie2');
	ele.list_all = $('#list-self');
	ele.empty1 = $('#empty1');
	ele.more1 = $('#more1');
	ele.list_today = $('#list-land');
	ele.empty2 = $('#empty2');
	ele.more2 = $('#more2');

	let page1 = 1;
	let page2 = 1;

	let list = [];
	let obj = {};


	pailist(page1);
	// 排行榜列表  金币排行榜
	function pailist(page) {
		let token = getCookie("token");
		ajax({
			url: API_PATH.GOLD_PAILIST,
			method: 'GET',
			header: {
				'Authorization': token,
			},
			data: {
				page: page
			},
			success: res => {
				if (res.code == 1) {
					let detail = res.data.list.data;
					if (detail.length === 0) {
						page1 = 0;
						ele.more1.style.display = "none";
						ele.empty1.style.display = "block";
					} else {
						drawgetGoldList(detail);
						page1++;
						if (page1 > res.data.list.last_page) {
							ele.more1.innerText = '没有更多了';
							ele.more1.onclick = null;
						} else {
							ele.more1.innerText = '加载更多';
							ele.more1.onclick = () => pailist(page1);
						}
					}
				} else openTips(res.msg || '未知错误');
			}
		});
	}

	// 金币兑换渲染 金币排行榜
	function drawgetGoldList(data) {
		if (data.length === 0) {
			page1 = 0;
			ele.more1.style.display = "none";
			ele.empty1.style.display = "block";
		} else {
			let str = '';
			for (let i = 0; i < data.length; i++) {
				let resume = data[i].remark;
				let sign = data[i].operation_type == 1 ? '+' : '-';
				let nick_name = data[i].detail != null ? data[i].detail.nick_name : ''
				let head_pic = '';
				// console.log(data[i].detail.head_pic);
				if (data[i].detail.head_pic != null) {
					head_pic = IMG_DOMAIN + data[i].detail.head_pic
				} else {
					if (data[i].detail.sex == 1) {
						head_pic = 'http://img.qxgs.cc/tiantianlaishouzu/img/my/tx1.png'
					} else {
						head_pic = 'http://img.qxgs.cc/tiantianlaishouzu/img/my/tx2.png'
					}
				}
				// console.log( data[i].rank);
				let rankimg = data[i].rank == 1 ? '<img class="rankimg" src="http://img.qxgs.cc/tiantianlaishouzu/img/rank/1.png">' : data[i].rank ==
					2 ? '<img class="rankimg" src="http://img.qxgs.cc/tiantianlaishouzu/img/rank/2.png">' : data[i].rank == 3 ?
					'<img class="rankimg" src="http://img.qxgs.cc/tiantianlaishouzu/img/rank/3.png">' : '<p class="rankimg rankimg2"><span>' + data[i]
					.rank + '</span></p>'
				str += '<div class="listonein listonein1">' +
					'<div class="left">' +
					rankimg +
					'<div class=" center1">' +
					'<img src="' + head_pic + '" alt="">' +
					'<span>' + nick_name + '</span>' +
					'</div>' +
					'</div>' +
					'<div class="chanzhi">' +
					'<img src="http://img.qxgs.cc/tiantianlaishouzu/img/home/jinbi.png" alt="">' +
					'<span>' + data[i].diamond + '</span>' +
					'</div>' +
					'</div>'
			}
			ele.list_all.innerHTML += str;
		}
	}



	syPhRecord(page2);
	// 排行榜列表  收益排行
	function syPhRecord(page) {
		let token = getCookie("token");
		ajax({
			url: API_PATH.SY_PH_RECORD,
			method: 'GET',
			header: {
				'Authorization': token,
			},
			data: {
				page: page
			},
			success: res => {
				if (res.code == 1) {
					let detail = res.data.list.data;
					if (detail.length === 0) {
						page2 = 0;
						ele.more2.style.display = "none";
						ele.empty2.style.display = "block";
					} else {
						drawgetSyList(detail);
						page2++;
						if (page2 > res.data.list.last_page) {
							ele.more2.innerText = '没有更多了';
							ele.more2.onclick = null;
						} else {
							ele.more2.innerText = '加载更多';
							ele.more2.onclick = () => syPhRecord(page2);
						}
					}
				} else openTips(res.msg || '未知错误');
			}
		});
	}

	// 金币兑换渲染 收益排行榜
	function drawgetSyList(data) {
		if (data.length === 0) {
			page1 = 0;
			ele.more1.style.display = "none";
			ele.empty1.style.display = "block";
		} else {
			let str = '';
			for (let i = 0; i < data.length; i++) {
				let resume = data[i].remark;
				let sign = data[i].operation_type == 1 ? '+' : '-';
				let nick_name = data[i].detail != null ? data[i].detail.nick_name : ''
				let head_pic = '';
				// console.log( data[i].rank);
				if (data[i].detail.head_pic != null) {
					head_pic = IMG_DOMAIN + data[i].detail.head_pic
				} else {
					if (data[i].detail.sex == 1) {
						head_pic = 'http://img.qxgs.cc/tiantianlaishouzu/img/my/tx1.png'
					} else {
						head_pic = 'http://img.qxgs.cc/tiantianlaishouzu/img/my/tx2.png'
					}
				}
				let rankimg = data[i].rank == 1 ? '<img class="rankimg" src="http://img.qxgs.cc/tiantianlaishouzu/img/rank/1.png">' : data[i].rank ==
					2 ? '<img class="rankimg" src="http://img.qxgs.cc/tiantianlaishouzu/img/rank/2.png">' : data[i].rank == 3 ?
					'<img class="rankimg" src="http://img.qxgs.cc/tiantianlaishouzu/img/rank/3.png">' : '<p class="rankimg rankimg2"><span>' + data[i]
					.rank + '</span></p>'
				str += '<div class="listonein listonein1">' +
					'<div class="left">' +
					rankimg +
					'<div class=" center1">' +
					'<img src="' + head_pic + '" alt="">' +
					'<span>' + nick_name + '</span>' +
					'</div>' +
					'</div>' +
					'<div class="chanzhi">'
					// +'<img src="http://img.qxgs.cc/tiantianlaishouzu/img/home/jinbi.png" alt="">'
					+
					'<span>+' + data[i].user_money + '</span>' +
					'</div>' +
					'</div>'
			}
			ele.list_today.innerHTML += str;
		}
	}


})()